package com.ruoyi.web.controller.campadmin;

import com.ruoyi.campadmin.domain.CaAmenity;
import com.ruoyi.campadmin.service.ICaAmenityService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.IdList.idList;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.campadmin.domain.CaCamp;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @Description  
 * @author kemonvvv
 * @Date 2023-06-05 
 */
@RestController
@RequestMapping("campadmin/caAmenity")
public class CaAmenityController extends BaseController {

    @Resource
    private ICaAmenityService caAmenityService;
    /**
     * 通过全查询
     *  params是用若依的特殊处理过的，不能直接用url去测试，只能用若依的主键写代码去测试
     */
    @PreAuthorize("@ss.hasPermi('campadmin:caAmenity:query')")
    @PostMapping("/getCaAmenityPage")
    public AjaxResult getCaAmenityPage(@RequestBody PageDomain pageDomain,@RequestBody CaAmenity caAmenity ,@RequestBody CaCamp caCamp) {
        Object data = caAmenityService.getCaAmenityPage(pageDomain, caAmenity, caCamp);
        return AjaxResult.success(data);
    }

    /**
     * 通过查询全部
     */
    @PreAuthorize("@ss.hasPermi('campadmin:caAmenity:query')")
    @PostMapping("/getCaAmenityList")
    public AjaxResult getCaAmenityList() {
        Object data = caAmenityService.getCaAmenityList();
        return AjaxResult.success(data);
    }
    
    /**
     * 通过id查询
     */
    @PreAuthorize("@ss.hasPermi('campadmin:caAmenity:query')")
    @PostMapping("/getCaAmenityById")
    public AjaxResult getCaAmenityById(@RequestBody Map<String,Long> idMap) {
        Object data = caAmenityService.getCaAmenityById(idMap.get("id"));
        return AjaxResult.success(data);
    }

    /**
     * 添加
     */
    @PreAuthorize("@ss.hasPermi('campadmin:caAmenity:add')")
    @PostMapping("/insertCaAmenity")
    public AjaxResult insertCaAmenity(@RequestBody CaAmenity caAmenity) {
        Object data = caAmenityService.insertCaAmenity(caAmenity);
        return AjaxResult.success(data);
    }

    /**
     * 更新
     */
    @PreAuthorize("@ss.hasPermi('campadmin:caAmenity:edit')")
    @PostMapping("/updateCaAmenity")
    public AjaxResult updateCaAmenity(@RequestBody CaAmenity caAmenity) {
        Object data = caAmenityService.updateCaAmenityById(caAmenity);
        return AjaxResult.success(data);
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('campadmin:caAmenity:remove')")
    @PostMapping("/deleteCaAmenityByIdList")
    public AjaxResult deleteCaAmenityByIdList(@RequestBody idList idList) {
        Object data = caAmenityService.deleteCaAmenityByIdList(idList.getIdList());
        return AjaxResult.success(data);
    }

}
